#include "Vehicle.h"

using namespace std;

#include <iostream>

Vehicle::Vehicle() : id(0),speed(0),acceleration(0.0f),choice(0),Drawable() {}

Vehicle::Vehicle(int id, float x, float y, float speed, float acceleration, EModel model, float orientation) : Drawable(x,y,orientation,model){
    this->id = id;
    this->speed = speed;
    this->acceleration = acceleration;
	this->choice = 0;
	this->posPrec = new Coord(x,y);
	this->canMove = true;
	this->delay = 0.0f;
}

int Vehicle::getId() const {
    return this->id;
}

void Vehicle::setId(int id) {
    this->id = id;
}

float Vehicle::getSpeed() const {
    return this->speed;
}

void Vehicle::setSpeed(float speed) {
    this->speed = speed;
}
float Vehicle::getDelay() const {
	return this->delay;
}
void Vehicle::setDelay(float delay){
	this->delay = delay;
}
float Vehicle::getAcceleration() const {
    return this->acceleration;
}

void Vehicle::setAcceleration(float acceleration) {
    this->acceleration = acceleration;
}

int Vehicle::getChoice() const {
	return this->choice;
}
bool Vehicle::getCanMove() const {
	return this->canMove;
}
void Vehicle::setCanMove(bool move) {
	this->canMove = move;
}
void Vehicle::setChoice(int choice){
	this->choice = choice;
}

Coord* Vehicle::getPosPrec() const{
	return this->posPrec;
}

void Vehicle::setPosPrec(Coord* posPrec){
	this->posPrec = posPrec;
}
int Vehicle::getSens(){
	return this->sens;
}
void Vehicle::setSens(int sens){
	this->sens=sens;
}
void Vehicle::toString() {
	cout << "Vehicle : " << this->id << endl;
}

//retourne vrai si le vehicule est en collision avec le vehicule parametre
bool Vehicle::collisionDetection(Vehicle* v) {

		return !(
			( v->getPosition()->getX() >= (this->getPosition()->getX() + ((this->getSize()->getX()+v->getSize()->getX())/2)))
			|| ((v->getPosition()->getX() + ((this->getSize()->getX()+v->getSize()->getX())/2)) <= this->getPosition()->getX())
			|| (v->getPosition()->getY() >= (this->getPosition()->getY() + ((this->getSize()->getX()+v->getSize()->getX())/2)))
			|| ((v->getPosition()->getY() + ((this->getSize()->getX()+v->getSize()->getX())/2)) <= this->getPosition()->getY())
			);
}
